package com.example.crm.servlet;

import com.example.crm.pojo.Customer;
import com.example.crm.service.CustomerService;
import com.example.crm.service.impl.CustomerServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/customerServlet")
public class CustomerServlet2 extends HttpServlet {

    @Override
    protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int id = Integer.parseInt(req.getParameter("cust_id"));
        System.out.println(id);
        CustomerService customerService = new CustomerServiceImpl();
        int i = customerService.deleteCustomer(id);
        if(i==1){
            req.getRequestDispatcher("/WEB-INF/jsp/customer/list.jsp").forward(req, resp);
        }
    }
}
